﻿#include "Validation.h"

#include "Util.h"

namespace Lisp
{
  void CheckArgsIs(const std::string &name, size_t got, size_t expectArgc)
  {
    LISP_CHECK(got == expectArgc, StringUtils::Format("%s: args size is %d, expect %d", name.c_str(), got, expectArgc));
  }

  size_t CheckArgsBetween(const std::string &name, size_t got, size_t min, size_t max)
  {
    LISP_CHECK(got >= min && got <= max, StringUtils::Format("%s: args size is %d, but should between %d and %d", name.c_str(), got, min, max));
    return got;
  }

  // 偶数个参数
  size_t CheckArgsEven(const std::string &name, size_t got)
  {
    LISP_CHECK(got % 2 == 0, StringUtils::Format("%s: args size is %d, but should be even", name.c_str(), got));
    return got;
  }

  size_t CheckArgsAtLeast(const std::string &name, size_t got, size_t min)
  {
    LISP_CHECK(got >= min, StringUtils::Format("%s: args size is %d, but should be at least %d", name.c_str(), got, min));
    return got;
  }
}